package com.quxiu.system.service.impl;

import java.util.Calendar;
import java.util.List;
import com.quxiu.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.quxiu.system.mapper.SysDataPushRecordMapper;
import com.quxiu.system.domain.SysDataPushRecord;
import com.quxiu.system.service.ISysDataPushRecordService;

import javax.annotation.Resource;

/**
 * 数据推送记录Service业务层处理
 *
 * @author GaoYang
 * @date 2024-01-19
 */
@Service
public class SysDataPushRecordServiceImpl implements ISysDataPushRecordService {
    @Resource
    private SysDataPushRecordMapper sysDataPushRecordMapper;

    /**
     * 查询数据推送记录
     *
     * @param recordId 数据推送记录主键
     * @return 数据推送记录
     */
    @Override
    public SysDataPushRecord selectSysDataPushRecordByRecordId(Long recordId) {
        return sysDataPushRecordMapper.selectSysDataPushRecordByRecordId(recordId);
    }

    /**
     * 查询数据推送记录列表
     *
     * @param sysDataPushRecord 数据推送记录
     * @return 数据推送记录
     */
    @Override
    public List<SysDataPushRecord> selectSysDataPushRecordList(SysDataPushRecord sysDataPushRecord) {
        return sysDataPushRecordMapper.selectSysDataPushRecordList(sysDataPushRecord);
    }

    @Override
    public void deleteHistoryPushData() {
        // 删除一个月前的数据
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH, -1);
        sysDataPushRecordMapper.deleteBeforeCreateTime(calendar.getTime());
    }
}
